<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterTableDormMetersAddResetColumn extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('dorm_meters', function (Blueprint $table) {
            Schema::hasColumn('dorm_meters', 'reset_limit') || $table->unsignedInteger('reset_limit')->after('unit')->default(100000);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('dorm_meters', function (Blueprint $table) {
            if (Schema::hasColumn('dorm_meters', 'reset_limit')) {
                $table->dropColumn('reset_limit');
            }
        });
    }
}
